package com.houger.ddd.datamanager.utils;

import lombok.Getter;

/**
 * @author martin
 * @date 2020/11/25
 */
public class BusinessException extends RuntimeException {

  /**
   * 状态码
   */
  private StatusCode statusCode;

  /**
   * 额外信息
   */
  @Getter
  private Object extra;

  public BusinessException(StatusCode statusCode) {
    super(statusCode.getMsg());
    this.statusCode = statusCode;
  }

  public BusinessException(StatusCode statusCode, Object extra) {
    super(statusCode.getMsg());
    this.statusCode = statusCode;
    this.extra = extra;
  }

  public BusinessException(String message, StatusCode statusCode, Object extra) {
    super(message);
    this.statusCode = statusCode;
    this.extra = extra;
  }

  public BusinessException(String message, Throwable cause, StatusCode statusCode, Object extra) {
    super(message, cause);
    this.statusCode = statusCode;
    this.extra = extra;
  }

  public BusinessException(Throwable cause, StatusCode statusCode, Object extra) {
    super(cause);
    this.statusCode = statusCode;
    this.extra = extra;
  }

  public BusinessException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, StatusCode statusCode, Object extra) {
    super(message, cause, enableSuppression, writableStackTrace);
    this.statusCode = statusCode;
    this.extra = extra;
  }

  public StatusCode getStatusCode() {
    return statusCode;
  }

  public Object getExtra() {
    return extra;
  }
}
